#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 20 17:25:57 2024

@author: ndrach
"""


import sys
# Insert path to advMSplot.py below
# sys.path.append('INSERT PATH HERE')

from advMSplot import *

import pandas as pd

''' 20 nm '''

log_file_path = 'Fig 1/d/OCT 15 2020 11-16.log' # log file path
cdf_file_path = 'Fig 1/d/OCT 15 2020 11-16.cdf' # CDF file path
tsv_file_path = 'Fig 1/d/ivpt3.tsv' # ivpt file path 


tsv_data = readIVPT(tsv_file_path)
mz_bins, combined_spec_data = process_cdf_file(cdf_file_path,log_file_path)
combined_data = combineFiles(tsv_data, combined_spec_data, mz_bins)

scan_start, scan_end = 100,20000
spec = sum_intensity_for_scan_range(combined_data, scan_start, scan_end)


mz = spec[0]
A = spec[1]

N = 30
mzsmooth = np.convolve(mz,np.ones(N)/N, mode = 'same')
Asmooth = np.convolve(A,np.ones(N)/N, mode = 'same')

fig, ax = plt.subplots()
ax.plot(mzsmooth, Asmooth/np.max(Asmooth))
ax.set_xlim(50,400)
ax.set_ylim(0,1.1)
ax.tick_params(direction = 'in')
ax.set_xlabel('m/z')
ax.set_ylabel('Norm. intensity')
